//
//  NSObject+Utils.m
//  cgdream
//
//  Created by ttouch on 16/6/2.
//  Copyright © 2016年 肖兰月. All rights reserved.
//

#import "NSObject+Utils.h"

@implementation NSObject (Utils)

// 设置SVProgressHUD样式
- (void)setSVProgressHUD {
    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleDark];
}

- (void)showSVProgressHUD {
    [self setSVProgressHUD];
    [SVProgressHUD show];
}

- (void)showSVProgressHUDWithStatus:(NSString *)status {
    [self setSVProgressHUD];
    [SVProgressHUD showWithStatus:status];
}

- (void)showSVProgressHUDInfoWithsStatus:(NSString *)status {
    [self setSVProgressHUD];
    [SVProgressHUD showInfoWithStatus:status];
}

- (void)ll_showAlertViewWithMessage:(NSString *)message confirmCallBack:(void (^)(void))confiemCallBack {
    [self ll_showAlertViewWithTitle:@"提示" message:message confirmCallBack:confiemCallBack];
}

- (void)ll_showAlertViewWithTitle:(NSString *)title message:(NSString *)message confirmCallBack:(void (^)(void))confiemCallBack {
    UIAlertController *vc = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *confirm = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        if (confiemCallBack) {
            confiemCallBack();
        }
    }];
    [vc addAction:confirm];
    [[UIViewController currentViewController] presentViewController:vc animated:YES completion:nil];
}



//- (void)showAlertViewWithTitle:(NSString *)title {
//    [self showAlertViewWithTitle:title message:nil];
//}
//
//- (void)showAlertViewWithTitle:(NSString *)title message:(NSString *)message {
//    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:message delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
//    [alert show];
//}

- (void)showAlertViewWithMessage:(NSString *)message {
    [self showAlertViewWithTitle:@"提示" message:message cancelBtnHandle:nil okBtnHandle:nil];
}

- (void)showAlertViewWithMessage:(NSString *)message okBtnHandle:(void (^)(void))okBtnHandle {
    [self showAlertViewWithTitle:@"提示" message:message cancelBtnHandle:nil okBtnHandle:okBtnHandle];
}

- (void)showAlertViewWithTitle:(NSString *)title message:(NSString *)message okBtnHandle:(void (^)(void))okBtnHandle {
    [self showAlertViewWithTitle:title message:message cancelBtnHandle:nil okBtnHandle:okBtnHandle];
}

- (void)showAlertViewWithTitle:(NSString *)title message:(NSString *)message cancelBtnHandle:(void (^)(void))cancelBtnHandle okBtnHandle:(void (^)(void))okBtnHandle {
    UIAlertController *vc = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        if (cancelBtnHandle) {
            cancelBtnHandle();
        }
    }];
    UIAlertAction *confirm = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        if (okBtnHandle) {
            okBtnHandle();
        }
    }];
    [vc addAction:cancel];
    [vc addAction:confirm];
    [[UIViewController currentViewController] presentViewController:vc animated:YES completion:nil];
}

- (void)showAlertViewWithTitle:(NSString *)title message:(NSString *)message leftActionTitle:(NSString *)leftActionTitle leftActionHandle:(void (^)(void))leftActionHandle rightActionTitle:(NSString *)rightActionTitle rightActionHandle:(void (^)(void))rightActionHandle {
    UIAlertController *vc = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *leftAction = [UIAlertAction actionWithTitle:leftActionTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        if (leftActionHandle) {
            leftActionHandle();
        }
    }];
    UIAlertAction *rightAction = [UIAlertAction actionWithTitle:rightActionTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        if (rightActionHandle) {
            rightActionHandle();
        }
    }];
    
    [rightAction setValue:LLColorRGB68 forKey:@"_titleTextColor"];
    [leftAction setValue:LLColorRGB153 forKey:@"_titleTextColor"];
    [vc addAction:leftAction];
    [vc addAction:rightAction];
    [[UIViewController currentViewController] presentViewController:vc animated:YES completion:nil];
}



@end
